package	hotciv.standard;

import hotciv.framework.*;
//import hotciv.variant.*;
import java.util.*;

/** Standard tile implementation. */

public class StandardTile implements Tile {


	protected Position position;
	protected String type;
	protected List<Unit> unitList;
	protected List<City> cityList;

	public StandardTile(String t, int r, int c) {
		position = new Position(r,c);
		type = t;
		unitList = new ArrayList<Unit>();
		cityList = new ArrayList<City>();
	}


	public boolean addUnit(Unit u) { 
		unitList.add(u);
		return true;
	}
	public List<Unit> getUnitList() { return unitList; }

	public Unit getTopUnit() {
		if(this.getUnitList().isEmpty()) return null;
		int lastIndex = this.getUnitList().size();
		return unitList.get(lastIndex-1); 
	}
	
	public void removeTopUnit() { unitList.remove(this.getTopUnit()); }

	public boolean addCity(City c) {
		if(!cityList.isEmpty()) return false;
		cityList.add(c);
		return true;
	}
	public List<City> getCityList() { return cityList; }


	public Position getPosition() { return position; }
	public String getTypeString() { return type; }

	public String toString() {
		return "Tile ("+position.getRow()+","+position.getColumn()+") Type: "+type;
	}
}
